<!--  温室气体  -->

<template>
  <div>
    <div class="m_contentBox">
      <a-card :bordered="false">
        <div class="m_aCardBox">
          <!-- 查询区域 -->
          <div class="tabBox">
            <div class="table-page-search-wrapper">
              <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">
                  <a-col :span="6">
                    <a-form-model-item label="温室气体">
                      <a-input placeholder="请输入" v-model="queryParam.gasName" allowClear></a-input>
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="6">
                  </a-col>
                  <a-col :span="6">
                  </a-col>
                  <a-col :span="6">
                    <a-form-model-item label="" style="">
                      <div style="width: 100%;display: flex;justify-content: flex-end;">
                        <a-button type="primary" @click="searchQuery()">查询</a-button>
                        <a-button @click="searchReset()" style="margin-left: 8px">重置</a-button>
                      </div>
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-form>
            </div>
          </div>
          <!-- 查询区域-END -->
          <!-- 操作按钮区域 -->
          <!-- table区域-begin -->
          <div class="cardBox">
            <div class="m_mb24">
              <a-button @click="handleAdd" type="primary" icon="plus">新增气体</a-button>
            </div>
            <a-table ref="table" size="middle" :scroll="{x:true}" bordered rowKey="id" :columns="columns"
                     :dataSource="dataSource" :pagination="ipagination" :loading="loading"
                     :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
                     class="j-table-force-nowrap" @change="handleTableChange">
              <span slot="action" slot-scope="text, record">
                <a @click="handleEdit(record)">编辑</a>
                <a-divider type="vertical"/>
                <a @click="handleDelete(record.id)">删除</a>
              </span>
            </a-table>
          </div>
          <cy-gas-store-modal ref="modalForm" @ok="modalFormOk"></cy-gas-store-modal>
        </div>
      </a-card>
    </div>
  </div>
</template>

<script>

import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import CyGasStoreModal from './modules/CyGasStoreModal'
import {deleteAction, getAction} from '../../../api/manage'

export default {
  name: 'CyGasStoreList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    CyGasStoreModal
  },
  data() {
    return {
      description: '温室气体库管理页面',
      queryParam: {},
      // 表头
      columns: [
        {
          title: '温室气体名称',
          align: "center",
          dataIndex: 'gasName'
        },
        {
          title: 'GWP值',
          align: "center",
          dataIndex: 'gwpValue'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: {customRender: 'action'}
        }
      ],
      url: {
        list: "/gas/cyGasStore/list",
        add: '/gas/cyGasStore/add',
        edit: '/gas/cyGasStore/edit',
        delete: "/gas/cyGasStore/delete",
        deleteBatch: "/CyGasStore/cyGasStore/deleteBatch",
        exportXlsUrl: "/CyGasStore/cyGasStore/exportXls",
        importExcelUrl: "CyGasStore/cyGasStore/importExcel",

      },
      dictOptions: {},
      superFieldList: [],
      dataSource: [],

    }
  },
  created() {
    this.getSuperFieldList();

  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    getList() {
      getAction(this.url.list).then(res => {
        this.dataSource = res.result.records
      })
    },
    initDictConfig() {
    },
    handleDelete(id) {
      deleteAction(this.url.delete, {id: id}).then(res => {
        if (res.code == 200) {
          this.$message.success(res.message)
          this.getList();
        }

      })
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({type: 'string', value: 'gasName', text: '温室气体名称', dictCode: ''})
      fieldList.push({type: 'BigDecimal', value: 'gwpValue', text: 'GWP值', dictCode: ''})
      fieldList.push({type: 'string', value: 'organizationId', text: '组织ID', dictCode: ''})
      fieldList.push({type: 'string', value: 'deptId', text: '部门ID', dictCode: ''})
      this.superFieldList = fieldList
    },
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';

/deep/ .ant-card-body {
  background: #F5F8F7;
}

.tabBox {
  padding: 24px 24px 0;
  background: #FFFFFF;
  border-radius: 3px;
}

.cardBox {
  margin-top: 24px;
  padding: 24px;
  background: #FFFFFF;
  border-radius: 3px;
}
</style>